/*
 * @Author: 千锋爱佛僧
 * @公众号: 大前端私房菜
 * @Slogan: 千锋精品教程，好学得不像实力派！
 */
/*
 * @Author: 千锋爱佛僧
 * @公众号: 大前端私房菜
 * @Slogan: 千锋精品教程，好学得不像实力派！
 */
/*
 * @Author: 千锋爱佛僧
 * @公众号: 大前端私房菜
 * @Slogan: 千锋精品教程，好学得不像实力派！
 */
import { createApp, defineAsyncComponent } from "vue";
import App from "./App.vue";
import router from "./router";
import "normalize.css"; //重置样式
import "animate.css"; //动画库
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import store from "./store";
// import ImgUpload from "./components/img-upload.vue";
import Cloud from "leancloud-storage";
import TransitionRouterView from "./components/transition-router-view.vue";

// LeanCloudSDK初始化
Cloud.init({
  appId: "JLjLPBuvkDdPOdOtWxo5vrTi-gzGzoHsz",
  appKey: "aBO9cNU8LlXNV7T06Wk6egM4",
  serverURL: "https://jljlpbuv.lc-cn-n1-shared.com",
});

//尝试提取本地存储用户信息
let info = localStorage.getItem("vue-admin-2301");
if (info) {
  store.commit("user/initInfoMute", JSON.parse(info));
}

let app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component); //全局注册图标组件
}
app.component(
  "img-upload",
  defineAsyncComponent(() => {
    //异步加载组件
    return import("@/components/img-upload.vue");
  })
); //全局注册自定义组件
app.component("TransitionRouterView", TransitionRouterView);
app.use(router); //注入路由
app.use(store); //注入状态机
app.mount("#app");
